from django.contrib.auth.models import AbstractUser,Group
from django.db import models
# Create your models here.


# 用户表
class Users(AbstractUser):
    nickname = models.CharField('昵称',max_length=10)
    head_src = models.FileField('头像地址',null=True)
    sign_time = models.DateTimeField('最后登录时间',auto_now=True)

    class Meta:
        db_table = '用户表'

# 题型
class QType(models.Model):
    title = models.CharField('题型名称',max_length=50)
    status = models.BooleanField('状态')

    class Meta:
        db_table = '题型表'


# 题库
class Question(models.Model):
    title = models.CharField('题目标题',max_length=50)
    content = models.TextField('题目内容')
    status = models.BooleanField('是否发布',default=True)
    type = models.ForeignKey(QType,on_delete=models.CASCADE,verbose_name='题目分类',related_name='children')
    degree = models.IntegerField('游览次数')

    class Meta:
        db_table = '题库表'

class Menu(models.Model):
    name = models.CharField('菜单名称',max_length=100)
    icon = models.CharField('图标',max_length=100)
    path = models.CharField('路径',max_length=100)
    role = models.ManyToManyField(Group,related_name='menu')

    class Meta:
        db_table = '菜单表'


    
